import com.hxl.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserApp {
    public static void main(String[] args) {

        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
//        UserService userService1 = (UserService) ctx.getBean("userService3");
//        UserService userService2 = (UserService) ctx.getBean("userService3");
//        UserService userService3 = (UserService) ctx.getBean("userService3");
//        System.out.println(userService1);
//        System.out.println(userService2);
//        System.out.println(userService3);
//        System.out.println(userService1 == userService2);

//        userService.save();

        /*ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService4 = (UserService)ctx.getBean("userService4");
        userService4.save();*/

     /*  ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
       UserService userService1 = (UserService) ctx.getBean("userService3");
       UserService userService2 = (UserService) ctx.getBean("userService3");
       UserService userService3 = (UserService) ctx.getBean("userService3");*/

      // ctx.close();


/*
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        UserService userService1 = ctx.getBean("userService", UserService.class);
        UserService userService2 = ctx.getBean("userService1", UserService.class);
        UserService userService3 = ctx.getBean("userService2", UserService.class);
        System.out.println(userService1==userService2);
        System.out.println(userService2==userService3);

        */
        UserService userService1 = (UserService) ctx.getBean("userService5");
        userService1.save();
    }
}
